/***
 * Copyright (C) 2011  wexoo
 * p.weixlbaumer@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.wexoo.group_cost_calculator.proxy;

import net.wexoo.group_cost_calculator.util.Log;
import android.content.Context;

/**
 * A factory for creating Proxy objects.
 * 
 * @author wexoo
 * @version Aug 27, 2011
 */
public class ProxyFactory {

   //   public static boolean ACCESS_MODE_CHANGED = false;

   private static final String TAG = ProxyFactory.class.getSimpleName();
   private static AbstractProxy proxy;

   /**
    * Chooses the proper proxy, creates a new one if needed and returns it
    * 
    * @author wexoo
    */
   public static AbstractProxy getProxy(Context context) {
      if (ProxyFactory.proxy == null) { // || ProxyFactory.ACCESS_MODE_CHANGED)
         // if (!Preferences.getStringPreference(R.string.lp_access_mode_key, null).equals("offline"))
         //         if (false) {
         //            Log.d(ProxyFactory.TAG, "New offline proxy created!");
         //            proxy = new OfflineProxy(context);
         //         } else {
         Log.d(ProxyFactory.TAG, "New offline ORMLite proxy created!");
         proxy = new OfflineORMLiteProxy(context);
         //         }

      }
      Log.d(ProxyFactory.TAG, "Accessing " + proxy.getClass() + "!");
      return ProxyFactory.proxy;
   }
}